<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title><spring:message code="changePassword.changePassword"></spring:message></title>
    <link href="${pageContext.request.contextPath }/phone/css/font/iconfont.css" rel="stylesheet" type="text/css" />
    <!--公共样式-->
    <link href="${pageContext.request.contextPath }/phone/css/public.css" rel="stylesheet" type="text/css" />
    <!--我的(个人中心)样式-->
    <link href="${pageContext.request.contextPath }/phone/css/mine.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!--头部 begin-->
<header class="page_topbar">
    <a href="javascript:history.go(-1);" class="back Hui-iconfont"></a>
    <div class="title"><spring:message code="changePassword.changePassword"></spring:message></div>
</header>
<!--头部 end-->
<div class="content contfff">
    <div class="load-type-inp">
	    <form style="display:none">
		  <input type="password"/>
		</form>
    	<input type="password" style="width:0;height:0;float:left;visibility:hidden"/>
        <div class="phone">
            <label><spring:message code="changePassword.originalPassword1"></spring:message>:</label>
           	<input type="password" id="passwordRaw" name="passwordRaw" minlength="6" maxlength="15" placeholder="<spring:message code="changePassword.pleaseEnterTheOriginalPassword"></spring:message>" />
        </div>
        <div class="secret">
            <label><spring:message code="changePassword.newPassword1"></spring:message>:</label>
            <input type="password" id="password" name="password" onkeyup="value=value.replace(/[^A-Za-z0-9]/,'')" minlength="6" maxlength="15" placeholder="<spring:message code="changePassword.pleaseEnterANewPassword"></spring:message>" />
        </div>
        <div class="secret">
            <label><spring:message code="changePassword.confirmNewPassword1"></spring:message>:</label>
            <input type="password" id="zpassword" name="zpassword" onkeyup="value=value.replace(/[^A-Za-z0-9]/,'')" minlength="6" maxlength="15" placeholder="<spring:message code="changePassword.pleaseEnterANewPasswordAgain"></spring:message>" />
        </div>
    </div>
    <div class="block-auto">
    	<a class="end-next" href="javascript:modifySubmit()"><spring:message code="changePassword.save"></spring:message></a>
   	</div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/layer_mobile/layer.js"></script>
<script type="text/javascript">
//提交修改密码
function modifySubmit(){
	var pass=$("#passwordRaw").val();
	var word=$("#zpassword").val();
	var pass1=$("#password").val();
	var password='';
	if(pass=='') {
		layer.open({
		    content: '<spring:message code="modifyPassword.originalPassword"></spring:message>'
		    ,skin: 'msg'
		    ,time: 1 //1秒后自动关闭
		  });
		return false;
	}else{
		$.ajax({
			type:"POST",
			url:"${pageContext.request.contextPath }/member/member/checkPassword",
			data:{
				passwordRaw:pass
			},
			success:function(data){
				if(data ==2){
					layer.open({
					    content: '<spring:message code="modifyPassword.passwordMistake"></spring:message>'
					    ,skin: 'msg'
					    ,time: 1 //1秒后自动关闭
					  });
					$("#passwordRaw").focus();
					return false;
				}
				if(data ==1){
					if(pass1=='') {
						layer.open({
						    content: '<spring:message code="modifyPassword.PasswordCannotEmpty"></spring:message>'
						    ,skin: 'msg'
						    ,time: 1 //1秒后自动关闭
						  });
						$("#password").focus();
						return false;
					}else if(pass1.length<6){
						layer.open({
						    content: '<spring:message code="modifyPassword.passwordLength"></spring:message>'
						    ,skin: 'msg'
						    ,time: 1 //1秒后自动关闭
						  });
						$("#password").focus(); 
						return false;
					}else if(pass1.length>15){
						layer.open({
						    content: '<spring:message code="modifyPassword.passwordTooLong"></spring:message>'
						    ,skin: 'msg'
						    ,time: 1 //1秒后自动关闭
						  });
						$("#password").focus(); 
						return false;
					}else{
						if(word == ""){
							 layer.open({
								    content: '<spring:message code="modifyPassword.confirm"></spring:message>'
								    ,skin: 'msg'
								    ,time: 1 //1秒后自动关闭
								  });
							 $("#zpassword").focus();
							 return false;
						 }
						 if(pass1!=word) {
							 layer.open({
								    content: '<spring:message code="modifyPassword.equally"></spring:message>'
								    ,skin: 'msg'
								    ,time: 1 //1秒后自动关闭
								  });
							 $("#zpassword").focus();
							  return false;
						  }else{
							  password+=$("#password").val(); 
							  $.ajax({
									type:"POST",
									url:"${pageContext.request.contextPath }/member/member/changePassword",
									data:{password:pass1},
									success:function(data){
										if(data!=1){
											layer.open({
											    content: '<spring:message code="modifyPassword.fail"></spring:message>'
											    ,skin: 'msg'
											    ,time: 1 //1秒后自动关闭
											  });
										}else{
											layer.open({
											    content: '<spring:message code="modifyPassword.success"></spring:message>'
											    ,skin: 'msg'
											    ,time: 1 //1秒后自动关闭
											  });
											window.setTimeout("top.location.href='${pageContext.request.contextPath }/api/toPhonePage/login'",2000);
										}
								} 
						   });
						  }
					}
				}
				
			}
		});
	}

} 
</script>
</body>
</html>